package com.itheima.day05_多态和内部类.develophomework01.homework02;

public class Music {
    public static void main(String[] args) {
        tune(new Wind());
        tune(new Brass());
    }
    public static void tune(Instrument i){
        i.play();
        if(i instanceof Wind){
            //此处是把InStrument向下转型
            ((Wind) i).play2();
        }
        if(i instanceof Brass){
            ((Brass) i).play2();
        }
    }
}
abstract class Instrument{
    public abstract void play();
}
class Wind extends Instrument{

    @Override
    public void play() {
        System.out.println("弹奏wind");
    }
    public void play2(){
        System.out.println("调用wind的play2");
    }
}
class Brass extends Instrument{

    @Override
    public void play() {
        System.out.println("弹奏brass");
    }
    public void play2(){
        System.out.println("调用brass的play2");
    }
}